linalg_least_squares Module



Interfaces

public interface solve_least_squares

  • private subroutine solve_least_squares_mtx(a, b, work, olwork, err)

    Solves the system of equations assuming matrix is of full rank.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, if M is greater than or equal to N, the QR factorization of in the form provided by qr_factor; else, if M is less than N, the LQ factorization of as returned by lq_factor.

    real(kind=real64), intent(inout), dimension(:,:) :: b

    If the system is overdetermined, the M-by-NRHS matrix ; else, the matrix should be sized as N-by-NRHS with the first M rows containing . On output, the first N rows will contain the solution matrix .

    real(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

  • private subroutine solve_least_squares_mtx_cmplx(a, b, work, olwork, err)

    Solves the system of equations assuming matrix is of full rank.

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, if M is greater than or equal to N, the QR factorization of in the form provided by qr_factor; else, if M is less than N, the LQ factorization of as returned by lq_factor.

    complex(kind=real64), intent(inout), dimension(:,:) :: b

    If the system is overdetermined, the M-by-NRHS matrix ; else, the matrix should be sized as N-by-NRHS with the first M rows containing . On output, the first N rows will contain the solution matrix .

    complex(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

  • private subroutine solve_least_squares_vec(a, b, work, olwork, err)

    Solves the system of equations assuming matrix is of full rank.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, if M is greater than or equal to N, the QR factorization of in the form provided by qr_factor; else, if M is less than N, the LQ factorization of as returned by lq_factor.

    real(kind=real64), intent(inout), dimension(:) :: b

    If the system is overdetermined, the M-element vector ; else, the array should be sized as N-element with the first M elements containing . On output, the first N rows will contain the solution vector .

    real(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

  • private subroutine solve_least_squares_vec_cmplx(a, b, work, olwork, err)

    Solves the system of equations assuming matrix is of full rank.

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, if M is greater than or equal to N, the QR factorization of in the form provided by qr_factor; else, if M is less than N, the LQ factorization of as returned by lq_factor.

    complex(kind=real64), intent(inout), dimension(:) :: b

    If the system is overdetermined, the M-element vector ; else, the array should be sized as N-element with the first M elements containing . On output, the first N rows will contain the solution vector .

    complex(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

public interface solve_least_squares_full

  • private subroutine solve_least_squares_mtx_pvt(a, b, ipvt, arnk, work, olwork, err)

    Solves the system of equations using a full orthogonal factorization of .

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, the matrix is overwritten by its orthogonal factorization.

    real(kind=real64), intent(inout), dimension(:,:) :: b

    If the system is overdetermined, the M-by-NRHS matrix ; else, the matrix should be sized as N-by-NRHS with the first M rows containing . On output, the first N rows will contain the solution matrix .

    integer(kind=int32), intent(inout), optional, target, dimension(:) :: ipvt

    An optional input that on input, an N-element array that if IPVT(I) .ne. 0, the I-th column of A is permuted to the front of A * P; if IPVT(I) = 0, the I-th column of A is a free column. On output, if IPVT(I) = K, then the I-th column of A * P was the K-th column of A. If not supplied, memory is allocated internally, and IPVT is set to all zeros such that all columns are treated as free.

    integer(kind=int32), intent(out), optional :: arnk

    An optional output, that if provided, will return the rank of .

    real(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

  • private subroutine solve_least_squares_mtx_pvt_cmplx(a, b, ipvt, arnk, work, olwork, rwork, err)

    Solves the system of equations using a full orthogonal factorization of .

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, the matrix is overwritten by its orthogonal factorization.

    complex(kind=real64), intent(inout), dimension(:,:) :: b

    If the system is overdetermined, the M-by-NRHS matrix ; else, the matrix should be sized as N-by-NRHS with the first M rows containing . On output, the first N rows will contain the solution matrix .

    integer(kind=int32), intent(inout), optional, target, dimension(:) :: ipvt

    An optional input that on input, an N-element array that if IPVT(I) .ne. 0, the I-th column of A is permuted to the front of A * P; if IPVT(I) = 0, the I-th column of A is a free column. On output, if IPVT(I) = K, then the I-th column of A * P was the K-th column of A. If not supplied, memory is allocated internally, and IPVT is set to all zeros such that all columns are treated as free.

    integer(kind=int32), intent(out), optional :: arnk

    An optional output, that if provided, will return the rank of .

    complex(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    real(kind=real64), intent(out), optional, target, dimension(:) :: rwork

    An optional input, that if provided, prevents any local memory allocation for real-valued workspaces. If not provided, the memory required is allocated within. If provided, the length of the array must be at least 2 * N.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

  • private subroutine solve_least_squares_vec_pvt(a, b, ipvt, arnk, work, olwork, err)

    Solves the system of equations using a full orthogonal factorization of .

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, the matrix is overwritten by its orthogonal factorization.

    real(kind=real64), intent(inout), dimension(:) :: b

    If the system is overdetermined, the M-element vector ; else, the array should be sized as N-element with the first M elements containing . On output, the first N rows will contain the solution vector .

    integer(kind=int32), intent(inout), optional, target, dimension(:) :: ipvt

    An optional input that on input, an N-element array that if IPVT(I) .ne. 0, the I-th column of A is permuted to the front of A * P; if IPVT(I) = 0, the I-th column of A is a free column. On output, if IPVT(I) = K, then the I-th column of A * P was the K-th column of A. If not supplied, memory is allocated internally, and IPVT is set to all zeros such that all columns are treated as free.

    integer(kind=int32), intent(out), optional :: arnk

    An optional output, that if provided, will return the rank of .

    real(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

  • private subroutine solve_least_squares_vec_pvt_cmplx(a, b, ipvt, arnk, work, olwork, rwork, err)

    Solves the system of equations using a full orthogonal factorization of .

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, the matrix is overwritten by its orthogonal factorization.

    complex(kind=real64), intent(inout), dimension(:) :: b

    If the system is overdetermined, the M-element vector ; else, the array should be sized as N-element with the first M elements containing . On output, the first N rows will contain the solution vector .

    integer(kind=int32), intent(inout), optional, target, dimension(:) :: ipvt

    An optional input that on input, an N-element array that if IPVT(I) .ne. 0, the I-th column of A is permuted to the front of A * P; if IPVT(I) = 0, the I-th column of A is a free column. On output, if IPVT(I) = K, then the I-th column of A * P was the K-th column of A. If not supplied, memory is allocated internally, and IPVT is set to all zeros such that all columns are treated as free.

    integer(kind=int32), intent(out), optional :: arnk

    An optional output, that if provided, will return the rank of .

    complex(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    real(kind=real64), intent(out), optional, target, dimension(:) :: rwork

    An optional input, that if provided, prevents any local memory allocation for real-valued workspaces. If not provided, the memory required is allocated within. If provided, the length of the array must be at least 2 * N.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

public interface solve_least_squares_svd

  • private subroutine solve_least_squares_mtx_svd(a, b, s, arnk, work, olwork, err)

    Solves the system of equations using a singular value decomposition of .

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, the matrix is overwritten.

    real(kind=real64), intent(inout), dimension(:,:) :: b

    If the system is overdetermined, the M-by-NRHS matrix ; else, the matrix should be sized as N-by-NRHS with the first M rows containing . On output, the first N rows will contain the solution matrix .

    real(kind=real64), intent(out), optional, target, dimension(:) :: s

    An optional MIN(M, N)-element array that on output contains the singular values of in descending order. Notice, the condition number of can be determined by S(1) / S(MIN(M, N)).

    integer(kind=int32), intent(out), optional :: arnk

    An optional output, that if provided, will return the rank of .

    real(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

  • private subroutine solve_least_squares_mtx_svd_cmplx(a, b, s, arnk, work, olwork, rwork, err)

    Solves the system of equations using a singular value decomposition of .

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, the matrix is overwritten.

    complex(kind=real64), intent(inout), dimension(:,:) :: b

    If the system is overdetermined, the M-by-NRHS matrix ; else, the matrix should be sized as N-by-NRHS with the first M rows containing . On output, the first N rows will contain the solution matrix .

    real(kind=real64), intent(out), optional, target, dimension(:) :: s

    An optional MIN(M, N)-element array that on output contains the singular values of in descending order. Notice, the condition number of can be determined by S(1) / S(MIN(M, N)).

    integer(kind=int32), intent(out), optional :: arnk

    An optional output, that if provided, will return the rank of .

    complex(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    real(kind=real64), intent(out), optional, target, dimension(:) :: rwork

    An optional input, that if provided, prevents any local memory allocation for real-valued workspaces. If not provided, the memory required is allocated within. If provided, the length of the array must be at least 5 * MIN(M, N).

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

  • private module subroutine solve_least_squares_vec_svd(a, b, s, arnk, work, olwork, err)

    Solves the system of equations using a singular value decomposition of .

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, the matrix is overwritten.

    real(kind=real64), intent(inout), dimension(:) :: b

    If the system is overdetermined, the M-element vector ; else, the array should be sized as N-element with the first M elements containing . On output, the first N rows will contain the solution vector .

    real(kind=real64), intent(out), optional, target, dimension(:) :: s

    An optional MIN(M, N)-element array that on output contains the singular values of in descending order. Notice, the condition number of can be determined by S(1) / S(MIN(M, N)).

    integer(kind=int32), intent(out), optional :: arnk

    An optional output, that if provided, will return the rank of .

    real(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.

  • private module subroutine solve_least_squares_vec_svd_cmplx(a, b, s, arnk, work, olwork, rwork, err)

    Solves the system of equations using a singular value decomposition of .

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=real64), intent(inout), dimension(:,:) :: a

    On input, the M-by-N matrix . On output, the matrix is overwritten.

    complex(kind=real64), intent(inout), dimension(:) :: b

    If the system is overdetermined, the M-element vector ; else, the array should be sized as N-element with the first M elements containing . On output, the first N rows will contain the solution vector .

    real(kind=real64), intent(out), optional, target, dimension(:) :: s

    An optional MIN(M, N)-element array that on output contains the singular values of in descending order. Notice, the condition number of can be determined by S(1) / S(MIN(M, N)).

    integer(kind=int32), intent(out), optional :: arnk

    An optional output, that if provided, will return the rank of .

    complex(kind=real64), intent(out), optional, target, dimension(:) :: work

    An optional input, that if provided, prevents any local memory allocation. If not provided, the memory required is allocated within. If provided, the length of the array must be at least olwork.

    integer(kind=int32), intent(out), optional :: olwork

    An optional output used to determine workspace size. If supplied, the routine determines the optimal size for work, and returns without performing any actual calculations.

    real(kind=real64), intent(out), optional, target, dimension(:) :: rwork

    An optional input, that if provided, prevents any local memory allocation for real-valued workspaces. If not provided, the memory required is allocated within. If provided, the length of the array must be at least 5 * MIN(M, N).

    class(errors), intent(inout), optional, target :: err

    The error object to be updated.